﻿@using Models;
@model IEnumerable<Models.Area>
@{
    ViewBag.Title = "单位查询";
}
@Html.ActionLink("创建", "Create")
@(Html.Telerik().Grid<Area>().Name("Area").DataBinding(binding => binding.Ajax().Select("AjaxAreaIndex", "Area"))
        .DataKeys(keys =>
        {
            keys.Add(a => a.ID);
        })
        .Columns(columns =>
        {
            columns.Bound(a => a.AreaName).Width(150);
            columns.Bound(a => a.Description).Width(550);
            columns.Bound(a => a.Sequence).Width(100);
            columns.Bound(a => a.ID).Title("操作").ClientTemplate("<a href='/Area/edit/" + "<#= ID #>'>编辑</a> | <a href='/Area/details/" + "<#= ID #>'>详细</a> | <a href='/Area/delete/" + "<#= ID #>'>删除</a>");
        })
        .ClientEvents(events => events.OnRowDataBound("warehouse_onAreaDataBound"))
            .DetailView(warehouseDetailView => warehouseDetailView.ClientTemplate(
                 Html.Telerik().Grid<Warehouse>()
                                .Name("warehouse_<#=ID#>")
                                .Columns(columns =>
                                {
                                    columns.Bound(w => w.WarehouseName).Width(200);
                                    columns.Bound(w => w.TotalVolume).Width(100);
                                    columns.Bound(w => w.Description).Width(400);
                                    columns.Bound(w => w.Sequence).Width(50);
                                })
                                .DataBinding(dataBinding => dataBinding.Ajax()
                                    .Select("AjaxWarehouseIndex", "Area", new
                                {
                                    areaID = "<#=ID#>"
                                }))
                                .DetailView(stockDetailView => stockDetailView.ClientTemplate(
                                    Html.Telerik().Grid<StockView>()
                                    .Name("stock_<#=ID#>")
                                    .Columns(columns =>
                                    {
                                        columns.Bound(s => s.StockName).Width(200);
                                        columns.Bound(s => s.CategoryName).Width(150);
                                        columns.Bound(s => s.QualityName).Width(150);
                                        columns.Bound(s => s.Volume).Width(100);
                                        columns.Bound(s => s.ID).Title("操作").ClientTemplate("<a href='/StockChangeRecord/StockReduce/" + "<#= ID #>'>转出</a> ");
                                    })
                                    .DataBinding(dataBinding => dataBinding.Ajax()
                                        .Select("AjaxStockIndex", "Area", new
                                        {
                                            warehouseID = "<#=ID#>"
                                        })).Resizable(resizing => resizing.Columns(true))
                                    .Groupable()
                                    .Pageable()
                                    .Sortable()
                                    .Filterable()
                                        .Scrollable(scrolling => scrolling.Height(350))
                                    .ToHtmlString()

                ))
                .Resizable(resizing => resizing.Columns(true))
                .Groupable()
                .Pageable()
                .Sortable()
                .Filterable()
                    .Scrollable(scrolling => scrolling.Height(350))
                .ToHtmlString()

        ))
        .Resizable(resizing => resizing.Columns(true))
        .Groupable()
        .Pageable()
        .Sortable()
        .Filterable()
        .Scrollable(scrolling => scrolling.Height(350))

)
